//
//  VIPWebController.swift
//  SeeFM_Swift
//
//  Created by CBCT_MBP on 2021/7/7.
//

import UIKit

class VIPWebController: WebController {

    
    var play = UIButton()
    
    override init(_ url: String, title: String? = nil) {
        super.init(url, title: title)
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        addPlayBtn()
        self.view.backgroundColor = UIColor.white
        // Do any additional setup after loading the view.
        self.webView?.backgroundColor = UIColor.white
    }
    
    func addPlayBtn() {
        // 播放按钮
        play.setTitle("播放", for: .normal)
        play.setTitleColor(.black, for: .normal)
        play.addTarget(self, action: #selector(playAction), for: .touchUpInside)
        play.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: play)
    }

    @objc func playAction() {
        let vc = VIPPlayController.init(url: self.webView?.url?.absoluteString)
        self.navigationController?.pushViewController(vc, animated: true)
    }

    override func backBtnAction() {
        if self.webView?.canGoBack == true {
            self.webView?.goBack()
        }else {
            super.backBtnAction()
        }
    }
}
